package NC86_矩阵元素查找;

import java.util.*;

public class Solution {
    public int[] findElement(int[][] mat, int n, int m, int x) {
        // write code here
        int[] res = new int[2];
        if (mat == null || n == 0 || m == 0){
            return null;
        }
        int row = n - 1, col = 0;

        while (row >= 0 && col < m){
            if (mat[row][col] == x){
                res[0] = row;
                res[1] = col;
                return res;
            }else if (mat[row][col] > x){
                row--;
            }else {
                col++;
            }
        }
        return res;
    }
}